/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSSerializer.cpp
 *
 *  Created on: 2010/02/23
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#include "RSSerializer.h"
#include <QVector4D>
#include <QVector3D>
#include <QVector2D>
#include <QMatrix4x4>
#include <QQuaternion>
#include <QVector>

namespace Realsphere {

    QString RSSerializer::serialize ( float value )
    {
        return QString::number ( value );
    }

    QString RSSerializer::serialize ( qreal value )
    {
        return QString::number ( value );
    }

    QString RSSerializer::serialize ( bool value )
    {
        if ( value )
            return QString ( "1" );

        return QString ( "0" );
    }

    QString RSSerializer::serialize ( const QVector4D& value )
    {
        QString w = QString::number ( value.w () );
        QString x = QString::number ( value.x () );
        QString y = QString::number ( value.y () );
        QString z = QString::number ( value.z () );

        return QString ( " " + x + " " + y + " " + z + " " + w );
    }

    QString RSSerializer::serialize ( const QVector3D& value )
    {
        QString x = QString::number ( value.x () );
        QString y = QString::number ( value.y () );
        QString z = QString::number ( value.z () );

        return QString ( x + " " + y + " " + z );
    }

    QString RSSerializer::serialize ( const QMatrix4x4& value )
    {
        QVector4D v1 = value.row ( 0 );
        QVector4D v2 = value.row ( 1 );
        QVector4D v3 = value.row ( 2 );
        QVector4D v4 = value.row ( 3 );

        QString l1 = serialize ( v1 );
        QString l2 = serialize ( v2 );
        QString l3 = serialize ( v3 );
        QString l4 = serialize ( v4 );

        return QString ( l1 + "\n" + l2 + "\n" + l3 + "\n" + l4 );
    }

    QString RSSerializer::serialize ( const QVector2D& value )
    {
        QString x = QString::number ( value.x () );
        QString y = QString::number ( value.y () );

        return QString ( x + " " + y );
    }

    QString RSSerializer::serialize ( int value )
    {
        return QString::number ( value );
    }

    QString RSSerializer::serialize ( const QString& value )
    {
        return value;
    }

    QString RSSerializer::serialize ( const QVector<bool>& value )
    {
        return QString::null;
    }

    QString RSSerializer::serialize ( const QVector<int>& value )
    {
        return QString::null;
    }

    QString RSSerializer::serialize ( const QVector<float>& value )
    {
        return QString::null;
    }

}
